package com.itheima.controller;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.constant.MessageConstant;
import com.itheima.constant.RedisMessageConstant;
import com.itheima.entity.Result;
import com.itheima.pojo.Setmeal;
import com.itheima.service.SetmealService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @author qzh
 * @create 2020-01-11 2020/1/11
 */

@RestController
@RequestMapping("setmeal")
public class SetmealController {

    @Reference
    private SetmealService setmealService;


    @RequestMapping("getAllSetmeal")
    public Result getAllSetmeal(){

        try {
            List<Setmeal> list = setmealService.findAll();
            System.out.println(list);

            return new Result(true, MessageConstant.GET_SETMEAL_LIST_SUCCESS,list);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false, MessageConstant.GET_SETMEAL_LIST_FAIL);
        }

    }


    @RequestMapping("findById")
    public Result findById(Integer id){

        try {
            Setmeal setmeal = setmealService.findCheckItemCheckGroupSetmealById(id);

            //Setmeal setmeal = setmealService.findCheckItemCheckGroupSetmealById(id);
            System.out.println(setmeal);

            return new Result(true, MessageConstant.QUERY_SETMEAL_SUCCESS,setmeal);
        } catch (Exception e) {
            e.printStackTrace();
            return new Result(false, MessageConstant.QUERY_SETMEAL_FAIL);
        }

    }

}
